import * as mongoose from "mongoose";
import {config} from "./config/config";
import logger from "./logger";

const connectDB = async () => {
    try {
        const url = `mongodb://${config.db.root}@${config.db.host}:${config.db.port}/${config.db.name}`
        // const url = `mongodb://${config.db.host}:${config.db.port}/${config.db.name}`
        await mongoose.connect(url, {
            maxPoolSize: 10
        });
    } catch (err) {
        logger.error(err);
        process.exit(1);
    }
};

export default connectDB;